home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / mawk10.zip / REXPDB.C < prev    next >
C/C++ Source or Header  |  1991-10-05  |  2KB  |  79 lines

  1.  
  2. /********************************************
  3. rexpdb.c
  4. copyright 1991, Michael D. Brennan
  5.  
  6. This is a source file for mawk, an implementation of
  7. the AWK programming language.
  8.  
  9. Mawk is distributed without warranty under the terms of
  10. the GNU General Public License, version 2, 1991.
  11. ********************************************/
  12.  
  13.  
  14. /*$Log:    rexpdb.c,v $
  15.  * Revision 3.2  91/08/13  09:10:09  brennan
  16.  * VERSION .9994
  17.  * 
  18.  * Revision 3.1  91/06/07  10:33:30  brennan
  19.  * VERSION 0.995
  20.  * 
  21. */
  22.  
  23.  
  24. #include "rexp.h"
  25. #include <ctype.h>
  26.  
  27. /*  print a machine for debugging  */
  28.  
  29. static  char *xlat[] = {
  30. "M_STR"  ,
  31. "M_CLASS" ,
  32. "M_ANY" ,
  33. "M_START" ,
  34. "M_END" ,
  35. "M_U",
  36. "M_1J" ,
  37. "M_2JA" ,
  38. "M_2JB" ,
  39. "M_ACCEPT" } ;
  40.  
  41. void  REmprint(m, f)
  42.   VOID *m ; FILE *f ;
  43. { register STATE *p = (STATE *) m ;
  44.   char *end_on_string ;
  45.  
  46.   while ( 1 )
  47.   { 
  48.     if ( p->type >= END_ON ) 
  49.     { p->type -= END_ON ; end_on_string = "$" ; }
  50.     else end_on_string = "" ;
  51.  
  52.     if ( p->type < 0 || p->type >= END_ON )
  53.     { fprintf(f, "unknown STATE type\n") ; return ; }
  54.  
  55.     fprintf(f, "%-10s" , xlat[p->type]) ;
  56.     switch( p->type )
  57.     {
  58.      case M_STR : fprintf(f, "%s", p->data.str ) ;
  59.                   break ;
  60.  
  61.      case M_1J:
  62.      case M_2JA:  
  63.      case M_2JB : fprintf(f, "%d", p->data.jump) ;
  64.                  break ;
  65.      case M_CLASS:
  66.           { unsigned char *q = (unsigned char *) p->data.bvp ;
  67.             unsigned char *r = q +  sizeof(BV) ;
  68.             while ( q < r )  fprintf(f, "%x " , *q++) ;
  69.           }
  70.           break ;
  71.     }
  72.     fprintf(f, "%s\n" , end_on_string) ;
  73.     if ( end_on_string[0] )  p->type += END_ON ;
  74.     if ( p->type == M_ACCEPT )  return ;
  75.     p++ ;
  76.    }
  77. }
  78.  
  79.